"""
@name : articles
@author : FanMY_71
@projectname: Selling-Idea
@Time: 2022/8/28-18:55
"""
from model import db
import datetime


class Articles(db.Model):
    article_id = db.Column(db.Integer, autoincrement=True, primary_key=True)
    title = db.Column(db.String(24), nullable=False)
    article_body = db.Column(db.Text, nullable=False)
    book_categories = db.Column(db.String(24), nullable=False)
    book_name = db.Column(db.String(24), nullable=False)
    user_id = db.Column(db.ForeignKey("users.user_id"))
    pageviews = db.Column(db.Integer, default=0)
    tags = db.Column(db.Integer, default=0)
    collects = db.Column(db.Integer, default=0)
    article_CreateAt = db.Column(db.DATETIME, default=datetime.datetime.now)
    article_UpdateAt = db.Column(db.DATETIME, default=datetime.datetime.now,onupdate=datetime.datetime.now)
    article_DeleteBit = db.Column(db.Enum("1"),default=None)
    check = db.Column(db.Enum("Y","N","null"),default=None)

    # 使用user_id属性去关联Users类，并为Users创建反向查询字段article
    # user_id = db.relationship("Users", backref="article", uselist=False)